{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# The Problem with Finding Domain Length and Area\n",
    "\n",
    "In order to find network properties such as permeability using Darcy's law, it is necessary to know the domain length and area.  At first glance this might seem as simple as finding the maxima and minima of the pore coordinates in the direction of interest; however it is a bit more subtle than that as will be explained in this notebook.  Consider the simple cubic network:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:19.238898Z",
     "iopub.status.busy": "2021-06-24T11:28:19.237329Z",
     "iopub.status.idle": "2021-06-24T11:28:19.817882Z",
     "shell.execute_reply": "2021-06-24T11:28:19.819079Z"
    }
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import openpnm as op\n",
    "%config InlineBackend.figure_formats = ['svg']\n",
    "import numpy as np\n",
    "np.random.seed(10)\n",
    "pn = op.network.Cubic(shape=[4, 4, 1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's plot the coordinates and connections between them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:19.826287Z",
     "iopub.status.busy": "2021-06-24T11:28:19.824704Z",
     "iopub.status.idle": "2021-06-24T11:28:20.144294Z",
     "shell.execute_reply": "2021-06-24T11:28:20.145450Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg height=\"262.19625pt\" version=\"1.1\" viewBox=\"0 0 385.78125 262.19625\" width=\"385.78125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2021-06-24T07:28:20.108680</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 262.19625 \n",
       "L 385.78125 262.19625 \n",
       "L 385.78125 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 43.78125 224.64 \n",
       "L 378.58125 224.64 \n",
       "L 378.58125 7.2 \n",
       "L 43.78125 7.2 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path d=\"M 0 11.18034 \n",
       "C 2.965061 11.18034 5.80908 10.002309 7.905694 7.905694 \n",
       "C 10.002309 5.80908 11.18034 2.965061 11.18034 0 \n",
       "C 11.18034 -2.965061 10.002309 -5.80908 7.905694 -7.905694 \n",
       "C 5.80908 -10.002309 2.965061 -11.18034 0 -11.18034 \n",
       "C -2.965061 -11.18034 -5.80908 -10.002309 -7.905694 -7.905694 \n",
       "C -10.002309 -5.80908 -11.18034 -2.965061 -11.18034 0 \n",
       "C -11.18034 2.965061 -10.002309 5.80908 -7.905694 7.905694 \n",
       "C -5.80908 10.002309 -2.965061 11.18034 0 11.18034 \n",
       "z\n",
       "\" id=\"m88f20cc021\" style=\"stroke:#ff0000;\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p316030b763)\">\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"112.344886\" xlink:href=\"#m88f20cc021\" y=\"214.756364\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"112.344886\" xlink:href=\"#m88f20cc021\" y=\"148.865455\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"112.344886\" xlink:href=\"#m88f20cc021\" y=\"82.974545\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"112.344886\" xlink:href=\"#m88f20cc021\" y=\"17.083636\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"178.235795\" xlink:href=\"#m88f20cc021\" y=\"214.756364\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"178.235795\" xlink:href=\"#m88f20cc021\" y=\"148.865455\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"178.235795\" xlink:href=\"#m88f20cc021\" y=\"82.974545\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"178.235795\" xlink:href=\"#m88f20cc021\" y=\"17.083636\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"244.126705\" xlink:href=\"#m88f20cc021\" y=\"214.756364\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"244.126705\" xlink:href=\"#m88f20cc021\" y=\"148.865455\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"244.126705\" xlink:href=\"#m88f20cc021\" y=\"82.974545\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"244.126705\" xlink:href=\"#m88f20cc021\" y=\"17.083636\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"310.017614\" xlink:href=\"#m88f20cc021\" y=\"214.756364\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"310.017614\" xlink:href=\"#m88f20cc021\" y=\"148.865455\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"310.017614\" xlink:href=\"#m88f20cc021\" y=\"82.974545\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"310.017614\" xlink:href=\"#m88f20cc021\" y=\"17.083636\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"ma82566f819\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"79.399432\" xlink:href=\"#ma82566f819\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(76.218182 239.238437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" id=\"DejaVuSans-30\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"145.290341\" xlink:href=\"#ma82566f819\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 1 -->\n",
       "      <g transform=\"translate(142.109091 239.238437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" id=\"DejaVuSans-31\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"211.18125\" xlink:href=\"#ma82566f819\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(208 239.238437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" id=\"DejaVuSans-32\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"277.072159\" xlink:href=\"#ma82566f819\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 3 -->\n",
       "      <g transform=\"translate(273.890909 239.238437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" id=\"DejaVuSans-33\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"342.963068\" xlink:href=\"#ma82566f819\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(339.781818 239.238437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-34\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_6\">\n",
       "     <!-- X -->\n",
       "     <g transform=\"translate(207.75625 252.916562)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M 403 4666 \n",
       "L 1081 4666 \n",
       "L 2241 2931 \n",
       "L 3406 4666 \n",
       "L 4084 4666 \n",
       "L 2584 2425 \n",
       "L 4184 0 \n",
       "L 3506 0 \n",
       "L 2194 1984 \n",
       "L 872 0 \n",
       "L 191 0 \n",
       "L 1856 2491 \n",
       "L 403 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-58\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-58\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"m1b45950efa\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"214.756364\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.5 -->\n",
       "      <g transform=\"translate(20.878125 218.555582)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" id=\"DejaVuSans-2e\" transform=\"scale(0.015625)\"/>\n",
       "        <path d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-35\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-35\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"181.810909\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 1.0 -->\n",
       "      <g transform=\"translate(20.878125 185.610128)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"148.865455\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 1.5 -->\n",
       "      <g transform=\"translate(20.878125 152.664673)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-35\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"115.92\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 2.0 -->\n",
       "      <g transform=\"translate(20.878125 119.719219)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"82.974545\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 2.5 -->\n",
       "      <g transform=\"translate(20.878125 86.773764)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-35\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"50.029091\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 3.0 -->\n",
       "      <g transform=\"translate(20.878125 53.82831)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#m1b45950efa\" y=\"17.083636\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 3.5 -->\n",
       "      <g transform=\"translate(20.878125 20.882855)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-35\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_14\">\n",
       "     <!-- Y -->\n",
       "     <g transform=\"translate(14.798438 118.973906)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M -13 4666 \n",
       "L 666 4666 \n",
       "L 1959 2747 \n",
       "L 3244 4666 \n",
       "L 3922 4666 \n",
       "L 2272 2222 \n",
       "L 2272 0 \n",
       "L 1638 0 \n",
       "L 1638 2222 \n",
       "L -13 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-59\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-59\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"LineCollection_1\">\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 214.756364 \n",
       "L 112.344886 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 148.865455 \n",
       "L 112.344886 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 82.974545 \n",
       "L 112.344886 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 214.756364 \n",
       "L 178.235795 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 148.865455 \n",
       "L 178.235795 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 82.974545 \n",
       "L 178.235795 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 214.756364 \n",
       "L 244.126705 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 148.865455 \n",
       "L 244.126705 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 82.974545 \n",
       "L 244.126705 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 310.017614 214.756364 \n",
       "L 310.017614 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 310.017614 148.865455 \n",
       "L 310.017614 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 310.017614 82.974545 \n",
       "L 310.017614 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 214.756364 \n",
       "L 178.235795 214.756364 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 148.865455 \n",
       "L 178.235795 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 82.974545 \n",
       "L 178.235795 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 112.344886 17.083636 \n",
       "L 178.235795 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 214.756364 \n",
       "L 244.126705 214.756364 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 148.865455 \n",
       "L 244.126705 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 82.974545 \n",
       "L 244.126705 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 178.235795 17.083636 \n",
       "L 244.126705 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 214.756364 \n",
       "L 310.017614 214.756364 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 148.865455 \n",
       "L 310.017614 148.865455 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 82.974545 \n",
       "L 310.017614 82.974545 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p316030b763)\" d=\"M 244.126705 17.083636 \n",
       "L 310.017614 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 43.78125 224.64 \n",
       "L 43.78125 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 378.58125 224.64 \n",
       "L 378.58125 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 43.78125 224.64 \n",
       "L 378.58125 224.64 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 43.78125 7.2 \n",
       "L 378.58125 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p316030b763\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"43.78125\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# NBVAL_IGNORE_OUTPUT\n",
    "fig, ax = plt.subplots()\n",
    "op.topotools.plot_coordinates(pn, markersize=500, ax=ax)\n",
    "op.topotools.plot_connections(pn, ax=ax)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's say we'd like to know the length of the domain from left to right.  The pore coordinates for the leftmost pores are:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.153932Z",
     "iopub.status.busy": "2021-06-24T11:28:20.152545Z",
     "iopub.status.idle": "2021-06-24T11:28:20.159524Z",
     "shell.execute_reply": "2021-06-24T11:28:20.158296Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.5, 0.5, 0.5],\n",
       "       [0.5, 1.5, 0.5],\n",
       "       [0.5, 2.5, 0.5],\n",
       "       [0.5, 3.5, 0.5]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pn['pore.coords'][pn.pores('left'), :]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the 'minimum' value is 0.5 rather than 0.0.  This is because the pore coordinates point to the center of the region that belongs to the pore.  In the case of the simple cubic with a spacing of 1, pore 0 lies at [0.5, 0.5, 0.5], while the bounding box around the pore goes from [0, 0, 0], to [1, 1, 1].  \n",
    "\n",
    "Therefore, if we use pore coordinates to find the domain length we'd do:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.167227Z",
     "iopub.status.busy": "2021-06-24T11:28:20.165972Z",
     "iopub.status.idle": "2021-06-24T11:28:20.170250Z",
     "shell.execute_reply": "2021-06-24T11:28:20.171319Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.0\n"
     ]
    }
   ],
   "source": [
    "L = pn['pore.coords'][:, 0].max() - pn['pore.coords'][:, 0].min()\n",
    "print(L)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "While in reality to domain is 4 pore long and the correct answer should be 4.0.  The extra 0.5 of the left and right cells are not included.  \n",
    "\n",
    "It may seem simple enough to automatically add a full lattice cell to the calculation, but this cannot be assumed since many networks are random.  Consider the Delaunay network:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.179001Z",
     "iopub.status.busy": "2021-06-24T11:28:20.177765Z",
     "iopub.status.idle": "2021-06-24T11:28:20.208212Z",
     "shell.execute_reply": "2021-06-24T11:28:20.206874Z"
    }
   },
   "outputs": [],
   "source": [
    "dn = op.network.Delaunay(points=20, shape=[1, 1, 0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's first remove the boundary pores to ensure the network is fully random:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.215597Z",
     "iopub.status.busy": "2021-06-24T11:28:20.214190Z",
     "iopub.status.idle": "2021-06-24T11:28:20.217056Z",
     "shell.execute_reply": "2021-06-24T11:28:20.218153Z"
    }
   },
   "outputs": [],
   "source": [
    "op.topotools.trim(network=dn, pores=dn.pores(['left', 'right', 'front', 'back']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.246831Z",
     "iopub.status.busy": "2021-06-24T11:28:20.240288Z",
     "iopub.status.idle": "2021-06-24T11:28:20.336995Z",
     "shell.execute_reply": "2021-06-24T11:28:20.338132Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg height=\"262.19625pt\" version=\"1.1\" viewBox=\"0 0 385.78125 262.19625\" width=\"385.78125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2021-06-24T07:28:20.299514</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.4.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 262.19625 \n",
       "L 385.78125 262.19625 \n",
       "L 385.78125 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 43.78125 224.64 \n",
       "L 378.58125 224.64 \n",
       "L 378.58125 7.2 \n",
       "L 43.78125 7.2 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path d=\"M 0 11.18034 \n",
       "C 2.965061 11.18034 5.80908 10.002309 7.905694 7.905694 \n",
       "C 10.002309 5.80908 11.18034 2.965061 11.18034 0 \n",
       "C 11.18034 -2.965061 10.002309 -5.80908 7.905694 -7.905694 \n",
       "C 5.80908 -10.002309 2.965061 -11.18034 0 -11.18034 \n",
       "C -2.965061 -11.18034 -5.80908 -10.002309 -7.905694 -7.905694 \n",
       "C -10.002309 -5.80908 -11.18034 -2.965061 -11.18034 0 \n",
       "C -11.18034 2.965061 -10.002309 5.80908 -7.905694 7.905694 \n",
       "C -5.80908 10.002309 -2.965061 11.18034 0 11.18034 \n",
       "z\n",
       "\" id=\"m2db4ac200f\" style=\"stroke:#ff0000;\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p9bdb9a7a1d)\">\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"272.927944\" xlink:href=\"#m2db4ac200f\" y=\"214.756364\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"211.79083\" xlink:href=\"#m2db4ac200f\" y=\"169.030261\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"137.973654\" xlink:href=\"#m2db4ac200f\" y=\"199.610027\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"100.960976\" xlink:href=\"#m2db4ac200f\" y=\"104.625346\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"261.820431\" xlink:href=\"#m2db4ac200f\" y=\"153.997866\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"221.659533\" xlink:href=\"#m2db4ac200f\" y=\"187.546755\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"199.09031\" xlink:href=\"#m2db4ac200f\" y=\"122.144976\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"245.829183\" xlink:href=\"#m2db4ac200f\" y=\"84.71494\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"303.702991\" xlink:href=\"#m2db4ac200f\" y=\"147.866528\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"125.619896\" xlink:href=\"#m2db4ac200f\" y=\"33.700634\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"222.78939\" xlink:href=\"#m2db4ac200f\" y=\"35.805889\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"178.880991\" xlink:href=\"#m2db4ac200f\" y=\"50.291458\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"173.022833\" xlink:href=\"#m2db4ac200f\" y=\"182.427035\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"284.084689\" xlink:href=\"#m2db4ac200f\" y=\"185.533909\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"321.401524\" xlink:href=\"#m2db4ac200f\" y=\"117.149697\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"233.946242\" xlink:href=\"#m2db4ac200f\" y=\"17.083636\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"108.879159\" xlink:href=\"#m2db4ac200f\" y=\"139.362961\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"174.189864\" xlink:href=\"#m2db4ac200f\" y=\"45.992666\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"170.650803\" xlink:href=\"#m2db4ac200f\" y=\"76.770159\"/>\n",
       "     <use style=\"fill:#ff0000;stroke:#ff0000;\" x=\"297.263811\" xlink:href=\"#m2db4ac200f\" y=\"48.365803\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"md88a690b19\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.256484\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- −0.2 -->\n",
       "      <g transform=\"translate(43.115078 239.238438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" id=\"DejaVuSans-2212\" transform=\"scale(0.015625)\"/>\n",
       "        <path d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" id=\"DejaVuSans-30\" transform=\"scale(0.015625)\"/>\n",
       "        <path d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" id=\"DejaVuSans-2e\" transform=\"scale(0.015625)\"/>\n",
       "        <path d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" id=\"DejaVuSans-32\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"100.076176\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 0.0 -->\n",
       "      <g transform=\"translate(92.124613 239.238438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"144.895868\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 0.2 -->\n",
       "      <g transform=\"translate(136.944305 239.238438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"189.71556\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 0.4 -->\n",
       "      <g transform=\"translate(181.763997 239.238438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-34\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"234.535252\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 0.6 -->\n",
       "      <g transform=\"translate(226.583689 239.238438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" id=\"DejaVuSans-36\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-36\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"279.354944\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 0.8 -->\n",
       "      <g transform=\"translate(271.403381 239.238438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" id=\"DejaVuSans-38\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-38\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"324.174636\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 1.0 -->\n",
       "      <g transform=\"translate(316.223073 239.238438)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" id=\"DejaVuSans-31\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"368.994328\" xlink:href=\"#md88a690b19\" y=\"224.64\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 1.2 -->\n",
       "      <g transform=\"translate(361.042765 239.238438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_9\">\n",
       "     <!-- X -->\n",
       "     <g transform=\"translate(207.75625 252.916563)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M 403 4666 \n",
       "L 1081 4666 \n",
       "L 2241 2931 \n",
       "L 3406 4666 \n",
       "L 4084 4666 \n",
       "L 2584 2425 \n",
       "L 4184 0 \n",
       "L 3506 0 \n",
       "L 2194 1984 \n",
       "L 872 0 \n",
       "L 191 0 \n",
       "L 1856 2491 \n",
       "L 403 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-58\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-58\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"md132f2f553\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#md132f2f553\" y=\"219.406844\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0.0 -->\n",
       "      <g transform=\"translate(20.878125 223.206062)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#md132f2f553\" y=\"174.587152\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.2 -->\n",
       "      <g transform=\"translate(20.878125 178.38637)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#md132f2f553\" y=\"129.76746\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 0.4 -->\n",
       "      <g transform=\"translate(20.878125 133.566678)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#md132f2f553\" y=\"84.947768\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 0.6 -->\n",
       "      <g transform=\"translate(20.878125 88.746986)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-36\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"43.78125\" xlink:href=\"#md132f2f553\" y=\"40.128075\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 0.8 -->\n",
       "      <g transform=\"translate(20.878125 43.927294)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSans-38\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_15\">\n",
       "     <!-- Y -->\n",
       "     <g transform=\"translate(14.798438 118.973906)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M -13 4666 \n",
       "L 666 4666 \n",
       "L 1959 2747 \n",
       "L 3244 4666 \n",
       "L 3922 4666 \n",
       "L 2272 2222 \n",
       "L 2272 0 \n",
       "L 1638 0 \n",
       "L 1638 2222 \n",
       "L -13 4666 \n",
       "z\n",
       "\" id=\"DejaVuSans-59\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-59\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"LineCollection_1\">\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 272.927944 214.756364 \n",
       "L 221.659533 187.546755 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 272.927944 214.756364 \n",
       "L 284.084689 185.533909 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 211.79083 169.030261 \n",
       "L 261.820431 153.997866 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 211.79083 169.030261 \n",
       "L 221.659533 187.546755 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 211.79083 169.030261 \n",
       "L 199.09031 122.144976 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 211.79083 169.030261 \n",
       "L 173.022833 182.427035 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 137.973654 199.610027 \n",
       "L 173.022833 182.427035 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 137.973654 199.610027 \n",
       "L 108.879159 139.362961 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 100.960976 104.625346 \n",
       "L 125.619896 33.700634 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 100.960976 104.625346 \n",
       "L 108.879159 139.362961 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 100.960976 104.625346 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 261.820431 153.997866 \n",
       "L 221.659533 187.546755 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 261.820431 153.997866 \n",
       "L 199.09031 122.144976 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 261.820431 153.997866 \n",
       "L 245.829183 84.71494 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 261.820431 153.997866 \n",
       "L 303.702991 147.866528 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 261.820431 153.997866 \n",
       "L 284.084689 185.533909 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 221.659533 187.546755 \n",
       "L 173.022833 182.427035 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 221.659533 187.546755 \n",
       "L 284.084689 185.533909 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 199.09031 122.144976 \n",
       "L 245.829183 84.71494 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 199.09031 122.144976 \n",
       "L 173.022833 182.427035 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 199.09031 122.144976 \n",
       "L 108.879159 139.362961 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 199.09031 122.144976 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 245.829183 84.71494 \n",
       "L 303.702991 147.866528 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 245.829183 84.71494 \n",
       "L 222.78939 35.805889 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 245.829183 84.71494 \n",
       "L 178.880991 50.291458 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 245.829183 84.71494 \n",
       "L 321.401524 117.149697 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 245.829183 84.71494 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 245.829183 84.71494 \n",
       "L 297.263811 48.365803 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 303.702991 147.866528 \n",
       "L 284.084689 185.533909 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 303.702991 147.866528 \n",
       "L 321.401524 117.149697 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 125.619896 33.700634 \n",
       "L 174.189864 45.992666 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 125.619896 33.700634 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 222.78939 35.805889 \n",
       "L 178.880991 50.291458 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 222.78939 35.805889 \n",
       "L 233.946242 17.083636 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 222.78939 35.805889 \n",
       "L 174.189864 45.992666 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 222.78939 35.805889 \n",
       "L 297.263811 48.365803 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 178.880991 50.291458 \n",
       "L 174.189864 45.992666 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 178.880991 50.291458 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 173.022833 182.427035 \n",
       "L 108.879159 139.362961 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 321.401524 117.149697 \n",
       "L 297.263811 48.365803 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 233.946242 17.083636 \n",
       "L 174.189864 45.992666 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 233.946242 17.083636 \n",
       "L 297.263811 48.365803 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 108.879159 139.362961 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "    <path clip-path=\"url(#p9bdb9a7a1d)\" d=\"M 174.189864 45.992666 \n",
       "L 170.650803 76.770159 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 43.78125 224.64 \n",
       "L 43.78125 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 378.58125 224.64 \n",
       "L 378.58125 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 43.78125 224.64 \n",
       "L 378.58125 224.64 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 43.78125 7.2 \n",
       "L 378.58125 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p9bdb9a7a1d\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"43.78125\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# NBVAL_IGNORE_OUTPUT\n",
    "fig, ax = plt.subplots()\n",
    "op.topotools.plot_coordinates(dn, markersize=500, ax=ax)\n",
    "op.topotools.plot_connections(dn, ax=ax)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now it's quite clear that finding the domain size by assuming a bounding box around the pore coordinates does not tell the whole story. How much 'extra' length should be added beyond the extreme pores?  This is not possible to know based only on the pore coordinates, which is the only information OpenPNM has."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The end result of this scenario is that when computing anything that requires length and area, these values must be specified by the user. Consider the permeability coefficient:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.345997Z",
     "iopub.status.busy": "2021-06-24T11:28:20.344205Z",
     "iopub.status.idle": "2021-06-24T11:28:20.388453Z",
     "shell.execute_reply": "2021-06-24T11:28:20.387134Z"
    }
   },
   "outputs": [],
   "source": [
    "pn = op.network.Cubic(shape=[4, 4, 4])\n",
    "geo = op.geometry.StickAndBall2D(network=pn, pores=pn.Ps, throats=pn.Ts)\n",
    "air = op.phases.Air(network=pn)\n",
    "phys = op.physics.Standard2D(network=pn, phase=air, geometry=geo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.397396Z",
     "iopub.status.busy": "2021-06-24T11:28:20.396008Z",
     "iopub.status.idle": "2021-06-24T11:28:20.542676Z",
     "shell.execute_reply": "2021-06-24T11:28:20.541993Z"
    }
   },
   "outputs": [],
   "source": [
    "sf = op.algorithms.StokesFlow(network=pn, phase=air)\n",
    "sf.set_value_BC(pores=pn.pores('left'), values=200000)\n",
    "sf.set_value_BC(pores=pn.pores('right'), values=100000)\n",
    "sf.run()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you do not specify the domain area and length, OpenPNM will attempt to estimate these values using the faulty logic of minima and maxima of boundary pores, but will issue a warning so you know that errors are present. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.547412Z",
     "iopub.status.busy": "2021-06-24T11:28:20.546709Z",
     "iopub.status.idle": "2021-06-24T11:28:20.553492Z",
     "shell.execute_reply": "2021-06-24T11:28:20.552893Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "------------------------------------------------------------\n",
      "WARNING    : Attempting to estimate inlet area...will be low \n",
      "SOURCE     : openpnm.algorithms.GenericTransport._get_domain_area \n",
      "TIME STAMP : 2021-06-23 22:17:42,418\n",
      "------------------------------------------------------------\n",
      "------------------------------------------------------------\n",
      "WARNING    : Attempting to estimate domain length...could be low if boundary pores were not added \n",
      "SOURCE     : openpnm.algorithms.GenericTransport._get_domain_length \n",
      "TIME STAMP : 2021-06-23 22:17:42,432\n",
      "------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.00152148]\n"
     ]
    }
   ],
   "source": [

    "K = sf.calc_effective_permeability()\n",
    "print(K)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To get correct answers, it is necessary to specify the domain sizes as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.558185Z",
     "iopub.status.busy": "2021-06-24T11:28:20.557620Z",
     "iopub.status.idle": "2021-06-24T11:28:20.561160Z",
     "shell.execute_reply": "2021-06-24T11:28:20.560576Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.00114111]\n"
     ]
    }
   ],
   "source": [
    "A = 16\n",
    "L = 4\n",
    "K = sf.calc_effective_permeability(domain_area=A, domain_length=L)\n",
    "print(K)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Of course, the most correct way to calculate K is to do it manually using Darcy's law:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-06-24T11:28:20.566217Z",
     "iopub.status.busy": "2021-06-24T11:28:20.565655Z",
     "iopub.status.idle": "2021-06-24T11:28:20.568723Z",
     "shell.execute_reply": "2021-06-24T11:28:20.569191Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.00114111]\n"
     ]
    }
   ],
   "source": [
    "mu = air['pore.viscosity'].mean()\n",
    "Q = sf.rate(pores=pn.pores('left'))\n",
    "dP = 200000 - 100000\n",
    "K = Q*mu*L/(A * dP)\n",
    "print(K)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
